package test.service;

import javax.annotation.Resource;

import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;

import com.shareach.dao.redis.impl.DeployRDao.DeployType;
import com.shareach.redis.NewJedis;
import com.shareach.redis.RedisService;

@ContextConfiguration(locations = { "classpath:**/applicationContext.xml" })
public class RemoveDeployesService extends AbstractJUnit4SpringContextTests {
	@Resource 
	private RedisService redisService;

	@Test
	public void removeDeploys() {
		//合并Redis
		mergRedisKeys();
		//删除Deploy的mong
		//删除Mysql数据
		
		
	}
	
//	private void removeMatches(){
//		//
//	}
	
	
	private void mergRedisKeys(){
		NewJedis redis = redisService.getJedis();
		//商户，合并3个key为一个，删除其他两个
		redisKeys(redis, DeployType.Shop);
		
		//活动商户
		redisKeys(redis, DeployType.ActivityShop);
		//活动
		redisKeys(redis, DeployType.Activity);
		
		//卡
		redisKeys(redis, DeployType.Card);
		
		//团购商户
		redisKeys(redis, DeployType.TuanShop);
		//团购
		redisKeys(redis, DeployType.Tuan);
	}
	private void redisKeys(NewJedis redis,DeployType type){
		//商户，合并3个key为一个，删除其他两个
		redis.zunionstore("dep:"+type.getCode()+":que", "dep:"+type.getCode()+":que","dep:"+type.getCode()+":err","dep:"+type.getCode()+":time");
		redis.del("dep:"+type.getCode()+":err","dep:"+type.getCode()+":time");
	}
}
